import requests
from requests.api import head
from requests.models import Response

url = 'https://baidu.com/s'

# 定义headers
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36 Edg/92.0.902.84',
    'Cookie': 'BIDUPSID=780A3BB931508E90829C4782F697D0F9; PSTM=1630571358; BAIDUID=780A3BB931508E903C2CE75E15172280:FG=1; BD_HOME=1; BAIDUID_BFESS=780A3BB931508E903C2CE75E15172280:FG=1; BD_UPN=12314753; delPer=0; BD_CK_SAM=1; PSINO=6; H_PS_PSSID=34445_34497_31660_33848_34524_34092_34505_26350_34421_34323; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; H_PS_645EC=f4ea/44N+4AK6CuxoqfTee1EyoXkdaUs2T6g92X9mFeHxUPy3HoaPdDyMBU; BA_HECTOR=25ah0h8l20ah2401vq1gj13i10r'
}
# 定义参数字典
params = {
    'word': 'bilibili'
}
response = requests.get(url, headers=headers, params=params)
response.encoding = 'utf-8'
with open('baidu.html', 'w', encoding='utf-8') as f:
    f.write(response.text)
